<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0054)http://technoplaza.suso.org/assembly/index.cgi?p=68ks1 -->
<HTML><HEAD><TITLE>Effective Addressing</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<META content="MSHTML 5.00.2314.1000" name=GENERATOR>
<link href="edit68k.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgColor=#ffffff>
<H1 class="heading">Flags<br>
    <hr noshade>
</H1>
<P><span class="text">Then we have the flags. They're stored in the status register (SR), a 16 bit register. It's divided into two parts, the system byte (bit 15-8) and the user byte (or flag register) (bit 7-0). Here's a description over the whole SR register:<BR>
          <BR>
  Bits 15 to 0 from most to least significant.</span>
<p class="sourcecode"><br>
  | T| -| S| -| -| I2,1,0 | -| -| -| X| N| Z| V| C| - the status register<br>
</p>
<span class="text">* The System byte<BR>
        <BR>
Bit 15: T - The trace bit. If it's set an interrupt will be called after each instruction. Often used in debuggers.<BR>
        <BR>
Bit 13: S - Supervisor bit. When this bit is set, you have more "access" to some instructions and also to the system byte. The reason for this is that it prevents programs to disturb the OS with some instructions that you shouldn't use if you're not writing an OS. Is enabled when interrupts are generated.<BR>
        <BR>
Bit 8-10: The interrupt mask<BR>
        <BR>
The I0, I1 and I2 bits of the system register are used to set the interrupt mask: in fact, it means that they are set to an interrupt level: if the trap generated has a level higher than the interrupt mask, then the trap is executed. Otherwise it is ignored. ( ignoring a trap generally means that another interrupt, with a higher priority is being treated )<BR>
        <BR>
Here is how these bits are set:<BR>
</span> <BR>
<p class="sourcecode">| I2 | I1 | I0 |<BR>
    <BR>
  level 0 | 0 0 0 | ---------&gt; lowest priority<BR>
  level 1 | 0 0 1 |<BR>
  level 2 | 0 1 0 |<BR>
  level 3 | 0 1 1 |<BR>
  level 4 | 1 0 0 |<BR>
  level 5 | 1 0 1 |<BR>
  level 6 | 1 1 0 |<BR>
  level 7 | 1 1 1 | ---------&gt; highest priority<BR>
</p>
<BR>
<BR>
<span class="text">Note: #0=%000; #1=%001; #2=%010; etc.<BR>
One should refer to the \system.txt file and \lesson\lesson_3.txt for more on interrupts.<BR>
        <BR>
        <BR>
* The flag register<BR>
        <BR>
- C-flag (Carry). Works as carry is used to work. If you add two 8 bit numbers, the C-flag will be the 9th bit. Also used with shift and rotation.<BR>
        <BR>
- V-flag (oVerflow). Will be set if a result can't be represented. For example, when you add $7F and $01, $80 can't be stored since that means -128 in two complement.<BR>
        <BR>
- Z-flag (Zero). Set if the result of an operation is zero.<BR>
        <BR>
- N-flag (Negative). If the highest bit in the result is set (in two complement it means the sign bit), N will be set.<BR>
        <BR>
- X-flag (eXtended). This flag is a copy of the carry-flag, but it won't be changed in all operations where C is changed. This allows you to first make a check (that will set C and X), then some other instructions that will change the C flag but not the X flag, and THEN you can make the branch according to the flags, which means you can use the X flag.
<p></P>
</span>
<H4 align=left> </H4>
</BODY></HTML>
